package cn.lysj.framework.coupon.repository;

import cn.lysj.framework.base.BaseRepository;
import cn.lysj.framework.coupon.domain.NewVipCouponConfig;
import cn.lysj.framework.coupon.vo.NewVipCouponToStoreVo;
import cn.lysj.framework.coupon.vo.NewVipCouponToUserVo;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author zwj
 * @description 新加入会员优惠券配置数据处理层
 * @create 2019-01-16 09:37:56
 **/
public interface NewVipCouponConfigRepository extends BaseRepository<NewVipCouponConfig> {

    @Query(value = "select new cn.lysj.framework.coupon.vo.NewVipCouponToStoreVo(a.id,a.couponId,b.name,b.fullReductionMoney,b.discountMoney,b.shareType,b.share,b.deadlineType,b.useBeginDate,b.useEndDate,b.validPeriod) " +
            "from NewVipCouponConfig a,Coupon b  where a.couponId = b.id and a.storeId = ?1 and b.delFlag = 1 order by a.createTime")
    List<NewVipCouponToStoreVo> findNewVipCouponToStoreVo(String storeId);

    NewVipCouponConfig findByStoreId(String storeId);

    @Query(value = "select new cn.lysj.framework.coupon.vo.NewVipCouponToUserVo(a.id,a.couponId,b.name,b.fullReductionMoney,b.discountMoney,b.shareType,b.share,b.validPeriod,b.eventTitle,b.eventInfo,b.eventImg) " +
            "from NewVipCouponConfig a,Coupon b where a.couponId = b.id and a.storeId = ?1 and b.delFlag = 1 order by a.createTime")
    List<NewVipCouponToUserVo> findNewVipCouponToUserVo(String storeId);
}
